<!--执行历史参数-单笔对-->
<template>
  <scroller class="scroller">
      <div class="wrapper" v-if="pairMap">
        
        <!--参数列表-->
        <VParam class="param" ref="param" 
        v-model="senior"
        :isModify="true"
        :isEdit="false"
        :isRestore="false"
        :reserves="reserves" 
        :investCoin="pairMap.investCoin" 
        :pairMap="pairMap"></VParam>

        <!--其他设置-->
        <VSet class="set" ref="set" 
        v-model="sets" 
        :isEdit="false"
        @open="setOpen"></VSet>
                
        <!--开放跟单-->
        <VSwitc class="follow" ref="follow" v-if="sets && sets.isOpen && showFollow" 
        v-model="isOpenFollow"
        :isEdit="false"
        :title="T('开放策略跟单')" 
        @change="followChange"></VSwitc>

        <div class="height80"></div>
      </div>
    </scroller>
</template>

<script>

//组件
import VParam from "@/up/view/VParam.vue";
import VSet from "@/up/view/VSet.vue";
import VSwitc from "@/public/view/VSwitc.vue";

//功能
import navigator from "@/_js/navigator"; 
import math from "@/_js/math";

const weexFunction = weex.requireModule("WeexFunction");
const dom = weex.requireModule('dom')

import I18N from "@/_i18n/i18n";
var T = I18N.t;
weexFunction.setTitle(T('参数'));

export default {

  components: {
    VParam,
    VSet,
    VSwitc,
  },

  data() {
    return {
      T:T,
      math:math,

      configMap:undefined, //执行配置
      isOpenFollow:false, //turn 开放跟单
      
      /************************************ 参数设置*/
      reserves:undefined, //参数数组
      pairMap:undefined, //交易对

      /************************************ 其他设置*/
      sets:undefined, //其他设置

      /************************************ 切换选中*/
      senior: true, //true 显示参数设置
      showFollow: false, //true 显示跟单
    };
  },

  mounted() {

    this.configMap = navigator.getParam('configMap');
    this.isOpenFollow = navigator.getParam('isOpenFollow');
    
    /************************************ 参数设置*/
    this.reserves = this.configMap.reserves;
    for (let index = 0; index < this.reserves.length; index++) {
      var reserve = this.reserves[index];
      delete reserve.comment;
    }
    var pairMap = this.configMap.tradePairs[0];

    /************************************ 其他设置*/
    var stopProfit = this.configMap.stopProfit.length ? math.cheng(this.configMap.stopProfit, '100') : '';
    var stopLoss = this.configMap.stopLoss.length ? math.cheng(this.configMap.stopLoss, '-100') : '';

    var pauseTime = this.configMap.pauseTime;
    var stopTime = this.configMap.stopTime;

    var cancelOrder = this.configMap.cancelOrder;
    var isConvert = this.configMap.isConvert;
    
    this.sets = { 
                'isOpen':true, //true 显示
                'isEdit':false, //true 可编辑
                'stopProfit':stopProfit, //止盈率
                'stopLoss':stopLoss, //止损率

                'pauseTime':pauseTime, //暂停时间戳
                'timeStopStamp':stopTime, //终止时间戳
                
                'cancelOrder':cancelOrder, //true 撤销订单
                'isConvert':isConvert, //true 兑换币种
              }
    this.showFollow = pairMap.apiId != '' || (pairMap.apiId == '' && this.isOpenFollow);

    this.pairMap = pairMap;
  },

  methods: {
    /********************************** 点击触发*/
    //其他设置-展开
    setOpen() {
      setTimeout(() => {
        if (this.$refs.follow) {
          dom.scrollToElement(this.$refs.follow, {offset:0});
        } else if (this.$refs.set) {
          dom.scrollToElement(this.$refs.set, {offset:0});
        }
      }, 100);
    },
  }
}
</script>


<style src="@/_css/style.css"></style>
<style scoped>
.scroller {
  top: 0;
  right: 0;
  left: 0;
  z-index: 9;
}
.wrapper {
  width: 750px;
}

.param{
  margin-top: 60px;
  margin-left: 40px;
  margin-right: 40px;
}
.set{
  margin-top: 40px;
  margin-left: 40px;
  margin-right: 40px;
}
.follow{
  margin-top: 40px;
  margin-left: 40px;
  margin-right: 40px;
}

.height80{
  height: 80px;
}
</style>